package com.example.webtask;

import java.io.File;

import com.android.myjson.http.HttpUtils;
import com.example.model.Album;
import com.example.uploadfile.UploadUtil;

import android.os.AsyncTask;

public class WebAsyncTask extends AsyncTask<String, Void, String> {
	private Album album;
	private File file;
	public WebAsyncTask(Album album, File file) {
		this.album = album;
		this.file = file;
	}
	@Override
	protected String doInBackground(String... url) {
		String jsonString = "";
		if(album != null) {
			//jsonString = HttpUtils.getJsonContent(url[0],"POST",album);
			if(file != null)
				jsonString = UploadUtil.uploadFile(file, url[0], album);
			else
				jsonString = HttpUtils.getJsonContent(url[0],"POST",album);
		} else {
			jsonString = HttpUtils.getJsonContent(url[0],"GET",null);
		}
		return jsonString;
	}

	 protected void onPostExecute(String result) {
	 }
}
